// Time Tracker by Eric Nadeau (nado18@gmail.com)
// Copyright (C) 2007 by Eric Nadeau
// Distributed under the terms of the GNU General Public License (see GPL.txt)

package view;

import java.awt.*;

import javax.swing.*;
import javax.swing.table.*;

/**
 * @author nado18@gmail.com, on Dec 29, 2005
 */
public class TableCells extends DefaultTableCellRenderer {
	public static final Color even = new Color(240, 240, 255);
	public static final Color odd = Color.WHITE;
	
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		
		setColor(isSelected, row, c);
		
		return c;
	}

	protected void setColor(boolean isSelected, int row, Component c) {
		if( ! isSelected ) {
			c.setForeground( SystemColor.textText );
			c.setBackground( row%2==0 ? even : odd );
		}
		else {
			c.setForeground( SystemColor.textHighlightText );
			c.setBackground( SystemColor.textHighlight );
		}
	}
}
